﻿Ext.onReady(function () {
    PageSafe();

    var page = new Ext.Viewport({
        layout: 'border',
        items: [{
            region: 'center',
            iconCls: 'updatepass-icon',
            title: '密码修改',
            layout: 'form',
            bodyStyle: 'padding: 10px',
            defaults: { xtype: 'textfield', style: 'margion-top:20px' },
            labelAlign: 'right',
            items: [{
                fieldLabel: '旧密码',
                width: 100,
                id: 'OldPass',
                name: 'OldPass'
            }, {
                fieldLabel: '新密码',
                width: 100,
                id: 'NewPass',
                name: 'NewPass'
            }, {
                fieldLabel: '新密码验证',
                width: 100,
                id: 'NewPass1',
                name: 'NewPass1'
            }, {
                xtype: 'button',
                text: '确定',
                iconCls: 'save-icon',
                handler: function () {
                    if (Ext.getCmp("OldPass").getValue() == "") {
                        Ext.Msg.alert("密码修改提示", "请输入旧密码");
                        return;
                    }
                    if (Ext.getCmp("NewPass").getValue() == "") {
                        Ext.Msg.alert("密码修改提示", "请输入新密码");
                        return;
                    }
                    if (Ext.getCmp("NewPass1").getValue() != Ext.getCmp("NewPass").getValue()) {
                        Ext.Msg.alert("密码修改提示", "密码验证不一致");
                        return;
                    }
                    var re = new JsonRequest();
                    re.params.OldPass = Ext.getCmp("OldPass").getValue();
                    re.params.NewPass = Ext.getCmp("NewPass").getValue();
                    Ext.Ajax.request({
                        url: Ext.getClassUrl('BaseManager.PersonManager.PersonView', 'UpdatePass'),
                        jsonData: re,
                        success: function (re, op) {
                            var obj = Ext.decode(re.responseText);
                            if (obj.ResponseObject != null) {
                                Ext.Msg.alert("用户密码提示", "用户密码修改成功");
                            }
                            else {
                                Ext.Msg.alert("用户密码提示", "用户密码修改失败，请联系管理员");
                            }
                        }
                    });
                }
            }]
        }]
    });
});